package cn.tedu.basic;

import java.time.Year;
import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;

//测试String 字符串
public class Test2_String {
    public static void main(String[] args) {
        //创建对象
        String s = new String();
        //特点：String底层是一个char[];String(char[]value);
        char[] value ={'m','a','k','e',' ','l','o','v','e', };
        String s1 =new String(value);
        //调用方法
        System.out.println(s1.charAt(3));
        System.out.println(s1.concat(" every day !"));
        System.out.println(s1.contains("love"));
        System.out.println(s1.endsWith("ve"));
        System.out.println(s1.equals("make love"));
        System.out.println(s1.hashCode());
        System.out.println(s1.indexOf("lo"));
        System.out.println(s1.lastIndexOf("lov"));
        System.out.println(s1.isEmpty());
        System.out.println(s1.length());
        System.out.println(s1.replace('l','k'));
        System.out.println(s1.startsWith("ma"));
        System.out.println(s1.substring(5));
        System.out.println(s1.substring(2,6));
        System.out.println(s1.toLowerCase());
        System.out.println(s1.toUpperCase());
        System.out.println(s1.toString());
        System.out.println(s1.trim());
        //把各种类型的数据转成String类型
        String st =String.valueOf(1000);
        System.out.println(st);
        //把该数组每个字符对应的整数存入byte[];
        byte[] by =s1.getBytes();
        System.out.println(Arrays.toString(by));
        //按照制定的规则切割字符串
        s1="you are my love !";
        String[] st1 =s1.split("y");
        System.out.println(Arrays.toString(st1));
        //接收用户输入的字符串，打印每个字符
        String input =new Scanner(System.in).nextLine();
        //遍历字符串
        for (int i = 0; i <input.length() ; i++) {
            //获取每个字符
            char c =input.charAt(i);
            System.out.println(c);

        }








    }
}
